<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="path" value="${pageContext.request.contextPath}"/>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
    <script language="javascript" src="${path}/js/AjaxRequest.js"></script>
    <script language="javascript" src="${path}/js/login.js"></script>
    <script language="javascript" src="${path}/js/jsonTest.js"></script>
    <title>企业信息管理系统_用户登录</title>
    <style type="text/css">
        <!--
        body {
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
            background-color: #016aa9;
            overflow: hidden;
        }

        .STYLE1 {
            color: #000000;
            font-size: 12px;
        }

        -->
    </style>
    <%--<script type="text/javascript">--%>
    <%--//创建一个XMLHttpRequest对象--%>
    <%--function createXHR() {--%>
    <%--var xmlhttp;--%>
    <%--if (window.ActiveXObject) {//判断浏览器是否支持ActiveX控件，如果浏览器支持ActiveX控件可以利用--%>
    <%--// var xml=new ActiveXObject("Microsoft.XMLHTTP");创建XMLHttpRequest 对象--%>
    <%--//IE浏览器--%>
    <%--xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");--%>
    <%--} else {--%>
    <%--xmlhttp = new XMLHttpRequest();--%>
    <%--}--%>
    <%--return xmlhttp;--%>
    <%--}--%>

    <%--var xmlhttp = createXHR();--%>
    <%--//验证用户名唯一--%>
    <%--function validName() {--%>
    <%--var username = document.getElementById("username").value;--%>
    <%--var password = document.getElementById("password").value;--%>
    <%--//GET方式请求--%>
    <%--//为XHR对象的onreadystatechange事件注册处理函数--%>
    <%--//            xmlhttp.onreadystatechange = handlerFun;--%>
    <%--//            xmlhttp.open('GET', encodeURI('/LoginServlet'), true);--%>
    <%--//            xmlhttp.send();--%>
    <%--//对于POST请求，将参数放在send()方法中，需要加上setRequestHeader()--%>
    <%--xmlhttp.open('POST', 'LoginServlet', true);--%>
    <%--xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");--%>
    <%--xmlhttp.send('username=' + username + '&password=' + password);--%>
    <%--//            //对于IE浏览器，下面一个语句应该放在最后--%>
    <%--xmlhttp.onreadystatechange = handlerFun;--%>
    <%--}--%>
    <%--//当XHR对象的状态发生改变调用此函数--%>
    <%--function handlerFun() {--%>
    <%--if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {--%>
    <%--//通过xmlhttp.responseText--%>
    <%--if (xmlhttp.responseText !== null && xmlhttp.responseText !== undefined && xmlhttp.responseText !== '') {--%>
    <%--var str = xmlhttp.responseText;--%>
    <%--//                    console.log(str)--%>
    <%--//                    var obj = eval('(' + str + ')');--%>
    <%--//                    console.log(obj);--%>
    <%--//                    console.log(obj.depts);--%>
    <%--//                    var obj1 = eval('(' + obj.depts + ')');--%>
    <%--//                    console.log(obj1);--%>
    <%--//                    var obj2 = eval(obj.depts);--%>
    <%--//                    console.log(obj2);--%>
    <%--var obj = JSON.parse(str);--%>
    <%--console.log(obj);--%>
    <%--var depts = JSON.parse(obj.depts);--%>
    <%--console.log(depts[0].deptName);--%>

    <%--} else {--%>
    <%--alert("fail");--%>
    <%--}--%>
    <%--}--%>
    <%--}--%>

    <%--</script>--%>
</head>
<body>
<form id="loginForm">
    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <table width="962" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                        <td height="235" background="${path}/images/login_03_副本.jpg">&nbsp;</td>
                    </tr>
                    <tr>
                        <td height="53">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td width="394" height="53" background="${path}/images/login_05.gif">&nbsp;</td>
                                    <td width="206" background="${path}/images/login_06.gif">
                                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <td width="16%" height="25">
                                                    <div align="right"><span class="STYLE1">用户</span></div>
                                                </td>
                                                <td width="57%" height="25">
                                                    <div align="center">
                                                        <input type="text" name="username" id="username"
                                                               style="width:105px; height:17px; background-color:#292929; border:solid 1px #7dbad7; font-size:12px; color:#6cd0ff">
                                                    </div>
                                                </td>
                                                <td width="27%" height="25">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="25">
                                                    <div align="right"><span class="STYLE1">密码</span></div>
                                                </td>
                                                <td height="25">
                                                    <div align="center">
                                                        <input type="password" name="password" id="password"
                                                               style="width:105px; height:17px; background-color:#292929; border:solid 1px #7dbad7; font-size:12px; color:#6cd0ff">
                                                    </div>
                                                </td>
                                                <td height="25">
                                                    <div align="left"><a href="javascript:void(0)"
                                                                         onclick="loginAjax()"><img
                                                            src="${path}/images/dl.gif" width="49" height="18"
                                                            border="0"></a></div>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td width="362" background="${path}/images/login_07.gif">&nbsp;</td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td height="213" background="${path}/images/login_08.gif">&nbsp;</td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</form>
</body>
</html>
<script>
    <c:if test="${!empty msg}">
    alert('${msg}');
    </c:if>
</script>